<?php
/**
 * 微信客服类
 * User: narnia
 * Date: 2017/5/19
 * Time: 11:24
 */
namespace LancerWechat;

class WechatKF extends WechatService
{
    public $key = 'kf';

    /**
     * 发送消息,详情见https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140547
     * @param array $data
     * @return string json
     */
    public function send(array $data)
    {
        $url = $this->getUrl([
            '{access_token}' => $this->config['global']['access_token']
        ], [$this->key, 'send']);
        if (is_array($data)) {
            $data = json_encode($data,JSON_UNESCAPED_UNICODE);
        }
        $result = \LancerWechat\WechatFunction::curl($url, $data);
        \LancerWechat\WechatLog::write($this->config['log']['path'], $result);
        return $result;
    }
}